package tech.zjp.ssm.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import tech.zjp.ssm.entity.User;

/**
 *
 * @Description: 
 * @Author: 周军鹏
 * @Date: 2020年2月28日 下午1:14:38
 */
public class SysInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		User user = (User) request.getSession().getAttribute("user");
		if (user == null) {
			response.sendRedirect(request.getContextPath()+"/login.jsp");
		}
		return super.preHandle(request, response, handler);
	}
	
}
